<!DOCTYPE html>
<html lang="en">  
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
	<title>常见问题</title>
</head>
<link rel="stylesheet" href="__CSS__/question.min.css">
<body>
	<div id="app" v-cloak>
		<div v-for="vo in arr" class="list">
			<div class="question" :class="{'active':index==vo.id}" @click="more(vo.id)">
				<span>{{vo.title}}</span>
				<span>开</span>
			</div>
			<div class="answer" v-if="index==vo.id">
				{{vo.content}}
			</div>
		</div>
		<div class="sfm">
			本服务由闪风猫提供
		</div>
	</div>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
	<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
	<script src="__JS__/vue.min.js"></script>
	<script src="__JS__/common.min.js"></script>
	<script>
		var app = new Vue({
			el: "#app",
			data: {
				arr: [],
				index: 0,
				last: '',
			},
			computed: {
				
			},
			mounted: function() {
				var url = location.href;
				var that = this;
				$.ajax({
					url: '{:U('setting/wxJsSDK')}',
					type: 'post',
					data: {
						url: url,
						code: 1
					},
					success: function(data) {
						if (data.code != 200) {
							alert(data.msg);
							return false;
						}
						that.wxdata = data.data;
						wx.config({
							debug: false, 
							appId: that.wxdata.appId, 
							timestamp: that.wxdata.timestamp, 
							nonceStr: that.wxdata.nonceStr, 
							signature: that.wxdata.signature,
							jsApiList: [
							"onMenuShareTimeline",   
							"onMenuShareAppMessage",  
							] 
						});
						var url2 = url.split('question/index').join('red/send')
						wx.ready(function(){
							$.ajax({
								url: '{:U('user/info')}',
								type: 'post',
								data: {},
								success: function(data) {
									console.log(data)
									that.userInfo = data;
								},
								error: function() {

								}
							})
							$.ajax({
								type: 'post',
								url: '{:U('question/lists')}',
								data: {},
								success: function(data) {
									that.arr = data.data;
								},
								error: function() {

								}

							})	
							wx.onMenuShareAppMessage({
								title: '口令红包等你来抢', 
								desc: '口令红包 说对算你赢', 
								link: url2,
								imgUrl: 'http://sfmhb.shanfengmao.com/logo.png', 
								type: '', 
								dataUrl: '', 
								success: function () { 
									
								},
								cancel: function () { 
									
								}
							});
							wx.onMenuShareTimeline({
								title: '口令红包等你来抢', 
								link: url2, 
								imgUrl: 'http://sfmhb.shanfengmao.com/logo.png', 
								success: function () { 
									
								},
								cancel: function () { 
									
								}
							});
						});
						wx.error(function(res){
							alert("调用失败")
						});
					},
					error: function() {

					}
				})
			},
			methods: {
				more: function(id) {
					console.log(id)
					if(id == this.last && this.index!=0) {
						this.index = 0;
					}else {
						this.index = id;
						this.last = id;
					}	
				}
			}
		})
	</script>
</body>
</html>